<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <style>
        .wrap {
            padding: 20px;
            width: 100%;
            overflow: auto;
            box-sizing: border-box;
        }

        ul {
            width: 100%;
        }

        ul li {
            width: 25%;
            float: left;
            height: 36px;
            line-height: 36px;
            /* background: #ccc; */
            text-align: center;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-top: 0px;
            cursor: pointer;
        }

        ul li:first-of-type {
            border: 1px solid #ccc;
        }

        ul li:nth-of-type(2) {
            border: 1px solid #ccc;
            border-left: 0px;

        }

        ul li:nth-of-type(3) {
            border: 1px solid #ccc;
            border-left: 0px;

        }

        ul li:nth-of-type(4) {
            border: 1px solid #ccc;
            border-left: 0px;

        }

        .winbody {
            width: 840px;
            padding: 10px;
        }

        .carlist {
            width: 140px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            font-size: 14px;
            display: inline-block;
            cursor: pointer;
            border: 1px solid #fff;
            box-sizing: border-box;
        }

        .tabs {
            /* width: 900px; */
        }

        .tabs a {
            width: 140px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            font-size: 14px;
            display: inline-block;
        }
        .lists {
            overflow: hidden;
            display: inline-block;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <ul id="list">

        </ul>
    </div>
    <div class="winbody" style="display:none;">
        <div class="lists">
            <div class="mcar">

            </div>
            <div class="gcar">

            </div>
        </div>
    </div>
</body>
<script src="./js/Global.js"></script>
<script>


    var cokeid = 1;



    function seeInfo(id) {

        $.ajax({
            url: API + '/erpManagement/gojianceweihuCar?custId=' + id,
            type: 'get',
            dataType: 'json',
            success: function (ret) {
                var objkache = ret.data.putongche;
                var objdagua = ret.data.guache;
                var mcar = ''
                var gcar = ''
                $.each(objkache,function (i,n)  {
                    let car = ''
                    if (n.carNumber) {
                        car = `(${n.carNumber})`
                    }
                    mcar += `<div data-userid='${cokeid}' data-id='${ n.carPlate}  ' onclick="seecarInfo('${n.carPlate}','${n.id}')"  class="carlist">${n.carPlate} ${car}</div>`;
                })
                $.each(objdagua,function (i,n)  {
                    let car = ''
                    if (n.carNumber) {
                        car = `(${n.carNumber})`
                    }
                    gcar += `<div data-userid='${cokeid}' data-id='${ n.carPlate}  ' onclick="seecarInfo('${n.carPlate}','${n.id}')" class="carlist">${n.carPlate} ${car}</div>`;
                })
                $('.mcar').html(mcar)
                $('.gcar').html(gcar)
            },
            error: function (err) {
                alert("系统错误");
            }
        });
        layui.use('layer', function () {
            let layer = layui.layer;
            layer.open({
                type: 1,
                area: ['860px','400px'],
                title: '车辆牌号',
                content: $('.winbody'),
            });
        })
    }
    $(function () {

        $.ajax({
            url: API + '/erpManagement/gojianceweihu?custId=' + loadUserInfo.customer.id,
            type: 'get',
            dataType: 'json',
            success: function (ret) {
                var obj = ret.data
                var html = '';

                for (var key = 0 ; key < obj.length; key ++) {
                    html += '<li onclick="seeInfo(' + obj[key].id + ')">' +
                        `<div>${obj[key].cusName}</div>` 
                        '</li>';
                }
                $("#list").html(html);
            },
            error: function (err) {
                alert("系统错误");

            }
        });

    })
    let pcar = ''
    let gcar = ''
    function seecarInfo (car,id) {
        console.log(car,'222')
        window.location.href = `cheliangluntaixiangqing.html?carnum=${encodeURI(encodeURI(car))}&id=${id}`

    }
</script>